update database 1

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



Euphoria Database System (EDS)

Introduction

While you can connect Euphoria to most databases (MySQL, SQLite, PostgreSQL, etc.), sometimes you don't need that kind of power. The Euphoria Database System (EDS) is a simple, easy-to-use, flexible, Euphoria-oriented database for storing data that works better for cases where you need more than a text file and don't quite need or want the power and complexity of larger database packages.

EDS Database Structure

In EDS, a database is "a single file with a .edb file extension." An EDS database contains zero or more tables. Each table has a name, and contains zero or more records. Each record consists of a key part, and a data part. The key can be any Euphoria object--an atom, a sequence, a deeply-nested sequence, whatever. Similarly the data can be any Euphoria object. There are no constraints on the size or structure of the key or data. Within a given table, the keys are all unique. That is, no two records in the same table can have the same key part.

The records of a table are stored in ascending order of key value. An efficient binary search is used when you refer to a record by key. You can also access a record directly, with no search, if you know its current record number within the table. Record numbers are integers from one to the length (current number of records) of the table. By incrementing the record number, you can efficiently step through all the records, in order of key. Note however that a record's number can change whenever a new record is inserted, or an existing record is deleted.

The keys and data parts are stored in a compact form, but no accuracy is lost when saving or restoring floating-point numbers or any other Euphoria data.

std/eds.e will work as is, on all platforms. EDS database files can be copied and shared between programs running on all platforms as well. When sharing EDS database files, be sure to make an exact byte-for-byte copy using "binary" mode copying, rather than "text" or "ASCII" mode, which could change the line terminators.

Example:

database: "mydata.edb" 
    first table: "passwords" 
        record #1:  key: "jones"   data: "euphor123" 
        record #2:  key: "smith"   data: "billgates" 
         
    second table: "parts" 
        record #1:  key: 134525    data: {"hammer", 15.95, 500} 
        record #2:  key: 134526    data: {"saw", 25.95, 100} 
        record #3:  key: 134530    data: {"screw driver", 5.50, 1500} 

It's up to you to interpret the meaning of the key and data. In keeping with the spirit of Euphoria, you have total flexibility. Unlike most other database systems, an EDS record is not required to have either a fixed number of fields, or fields with a preset maximum length.

In many cases there will not be any natural key value for your records. In those cases you should simply create a meaningless, but unique, integer to be the key. Remember that you can always access the data by record number. It's easy to loop through the records looking for a particular field value.

Accessing Data

To reduce the number of parameters that you have to pass, there is a notion of the current database, and current table.

Search



Quick Links

User menu

Not signed in.

Misc Menu